package cn.xinfei.xdecision.engine.runner.executor;

import cn.xinfei.xdecision.XDecisionEngineServerApplicationTest;
import cn.xinfei.xdecision.common.model.enginex.po.EngineNode;
import cn.xinfei.xdecision.common.utils.enums.enginex.NodeTypeEnum;
import cn.xinfei.xdecision.engine.runner.context.PipelineMetaInfoContext;
import org.junit.Before;

public abstract class AbstractNode extends XDecisionEngineServerApplicationTest {

    protected PipelineMetaInfoContext engineNodeMap = new PipelineMetaInfoContext();

    @Before
    public void buildDecisionFlow(){
        buildStartNode();

        build();

        buildEndNode();

    }

    public abstract void build();


    protected EngineNode buildStartNode(){
        EngineNode startNode=new EngineNode();
        engineNodeMap.put("START_NODE",new NodeHandler(startNode, NodeTypeEnum.START.getType()));
        return startNode;
    }



    protected EngineNode buildEndNode(){
        EngineNode startNode=new EngineNode();
        startNode.setNodeType(NodeTypeEnum.END.getType());
        startNode.setNodeCode("END_NODE");
        startNode.setNodeName("结束节点");
        engineNodeMap.put(startNode.getNodeCode(),new NodeHandler(startNode,NodeTypeEnum.END.getType()));
        return startNode;
    }
}
